package com.imooc.controller;

import com.imooc.pojo.Stu;
import com.imooc.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author gcq
 * @Create 2022-01-02
 */
@RestController
public class StuFooController
{

    @Autowired
    StuService stuService;

    @GetMapping("/getStu/{id}")
    public Object getStu(@PathVariable Integer id)
    {
        Stu stuInfo = stuService.getStuInfo(id);
        return stuInfo;
    }

    @PostMapping("/saveStu")
    public Object saveStu(Stu stu)
    {
        stuService.saveStu(stu);
        return "ok";
    }

    @PostMapping("/updateStu")
    public Object updateStu(Stu stu)
    {
        stuService.updateStu(stu);
        return "ok";
    }

    @PostMapping("/deleteStu")
    public Object deleteStu(Integer id)
    {
        Integer result = stuService.deleteStu(id);
        return result;
    }
}